<template>
    <div class="model" v-show="modelToggle">
        <transition name="toggle">
            <div class="model-box" v-if="modelToggle && boxShow">
                <div class="model-title">
                    <div class="title">{{currData.name}}</div>
                    <div class="person-info">
                        <div class="portrait">
                            <img src="~images/portrait.png" alt="banner"/>
                        </div>
                        <div class="info-text">
                            <div class="name">小美</div>
                            <div class="department">用户体验部门</div>
                        </div>
                    </div>
                    <div class="title-right">
                        <div @click="close"><img src="~images/close.png" alt="banner"/></div>
                    </div>
                </div>
                <div class="old-edtion">
                    <div class="old-edition-pc" v-if="currData.type === 'pc'"></div>
                    <div class="old-edition-mobile" v-else-if="currData.type === 'mobile'"></div>
                    <div class="old-edition-component" v-else></div>
                </div>
                <div class="old-edtion-tit">旧版</div>
                <div class="old-edition-describe">这里是对旧版本的一些说明这里是对旧版本的一些说明这里是对旧版本的一些说明这里是对旧版本的一些说明这里是对旧版本的一些说明这里是对旧版本的一些说明这里是对旧版本的一些说明这里是对旧版本的一些说明这里是对旧版本的一些说明这里是对旧版本的一些说明这里是对旧版本的一些说明</div>
                <div class="old-edtion-num">2020.09.20 编号001</div>
                <div class="new-edtion">
                    <div class="new-edition-pc" v-if="currData.type === 'pc'"></div>
                    <div class="new-edition-mobile" v-else-if="currData.type === 'mobile'"></div>
                    <div class="new-edition-component" v-else></div>
                </div>
                <div class="new-edtion-tit">新版</div>
                <div class="new-edition-describe">这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明这里是对优化后的说明</div>
                <div class="new-edtion-num">2020.09.20 编号001</div>
                <div class="bottom-nav">
                    <div class="bottom-nav-left" :class="[currIndex === 0 && 'disabled']" @click="preview(currIndex - 1)">上一篇：{{currIndex === 0 ? '无' : allContent[currIndex - 1].name}}</div>
                    <div class="bottom-nav-right" :class="[!allContent[currIndex + 1] && 'disabled']" @click="preview(currIndex + 1)">下一篇：{{allContent[currIndex + 1] ? allContent[currIndex + 1].name : '无'}}</div>
                </div>
            </div>
        </transition>
    </div>
</template>

<script>

export default {
    name: 'Model',
    props: {
        modelToggle: {
            type: Boolean,
            default: false
        },
        allContent: {
            type: Array,
            default: () => []
        },
        currIndex: {
            type: Number,
            default: 0
        }
    },
    data() {
        return {
            boxShow: true,
            currData: {}
        }
    },
    mounted() {
        this.currData = this.allContent[this.currIndex];
    },
    created() {},
    watch: {
        currIndex(n) {
            this.currData = this.allContent[n];
        }
    },
    methods: {
        close() {
            this.boxShow = false;
            setTimeout(() => {
                this.$emit('closeModel');
                this.$nextTick(() => {
                    this.boxShow = true;
                });
            }, 360);
        },
        preview (index) {
            this.$emit('preview', index);
        }
    }
};
</script>

<style lang="less">
.model{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    padding-top: 30px;
    overflow-y: auto;
    &-box{
        width: 1200px;
        margin: 0 auto 30px auto;
        background-color: #ffffff;
        padding: 46px 50px 55px 50px;
        .bottom-nav{
            margin-top: 90px;
            display: flex;
            justify-content: center;
            .bottom-nav-left{
                height: 20px;
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                color: #0091FF;
                line-height: 20px;
                margin-right: 71px;
                cursor: pointer;
            }
            .bottom-nav-right{
                height: 20px;
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                color: #0091FF;
                line-height: 20px;
                cursor: pointer;
            }
            .disabled {
                pointer-events: none;
                cursor: not-allowed;
                color: #646C73;
            }
        }
        .old-edtion{
            margin-top: 28px;
            .old-edition-pc,.old-edition-mobile,.old-edition-component{
                background-color: #FFD1D1;
            }
        }
        .new-edtion{
            margin-top: 47px;
            .new-edition-pc,.new-edition-mobile,.new-edition-component{
                background-color: #9ED5FF;
            }
        }
        .new-edtion,
        .old-edtion{
            height: 628px;
            background-color: #EBF0F6;
            padding: 32px 49px;
            display: flex;
            align-items: center;
            justify-content: center;
            .old-edition-pc,
            .new-edition-pc{
                width: 1002px;
                height: 563px;
            }
            .old-edition-mobile,
            .new-edition-mobile{
                width: 340px;
                height: 563px;
            }
            .old-edition-component,
            .new-edition-component{
                width: 474px;
                height: 345px;
            }
        }
        .new-edtion-tit,
        .old-edtion-tit{
            height: 25px;
            font-size: 18px;
            font-family: PingFangSC-Semibold, PingFang SC;
            font-weight: 600;
            color: #1F2529;
            line-height: 25px;
            padding-left: 49px;
            margin-top: 33px;
        }
        .new-edition-describe,
        .old-edition-describe{
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            color: #646C73;
            line-height: 22px;
            padding-left: 49px;
            padding-right: 49px;
            margin-top: 20px;
        }
        .new-edtion-num,
        .old-edtion-num{
            height: 20px;
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            color: #646C73;
            line-height: 20px;
            padding-left: 49px;
            margin-top: 20px;
        }
        .model-title{
            display: flex;
            align-items: center;
            .title-right{
                flex-grow: 1;
                align-self: start;
                >div{
                    height: 30px;
                    width: 30px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    float: right;
                    margin-right: -8px;
                    margin-top: -8px;
                    cursor: pointer;
                    img{
                        width: 24px;
                        height: 24px;
                    }
                }
            }
            .person-info{
                display: flex;
                align-items: center;
                .info-text{
                    .name{
                        font-size: 14px;
                        font-family: PingFangSC-Semibold, PingFang SC,serif;
                        font-weight: 600;
                        color: #1F2529;
                        line-height: 20px;
                    }
                    .department{
                        font-size: 12px;
                        font-family: PingFangSC-Regular, PingFang SC,serif;
                        font-weight: 400;
                        color: #646C73;
                        line-height: 17px;
                    }
                }
                .portrait{
                    width: 37px;
                    height: 36px;
                    margin-right: 12px;
                    img {
                        width: 100%;
                        height: 100%;
                    }
                }
            }
            .title {
                width: 258px;
                height: 45px;
                font-size: 32px;
                font-family: PingFangSC-Semibold, PingFang SC, serif;
                font-weight: 600;
                color: #1F2529;
                line-height: 45px;
            }
        }
    }
}
@keyframes toggle{
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
  /* from {
    // transform: scale(0.2, 0.2);
    transform: translate3d(0, -100px, 0);
    opacity: 0;
  }
  to {
    // transform: rotate(1, 1);
    transform: translate3d(0, 0, 0);
    opacity: 1;
  } */
    /* 0% {
        -webkit-transform: translate3d(0, -20%, 0);
        -webkit-transform: translate3d(0, -20%, 0);
        transform: translate3d(0, -20%, 0);
        transform: translate3d(0, -20%, 0);
        opacity: 0;
    }
    100% {
        -webkit-transform: none;
        transform: none;
        opacity: 1;
    } */
    /* 0% {
        -webkit-transform: scale3d(0, 0, 0);
        transform: scale3d(0.5, 0.5, 0.5);
        opacity: 0;
    }
    50% {
        -webkit-animation-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715);
        animation-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715);
    }
    100% {
        -webkit-transform: scale3d(1, 1, 1);
        transform: scale3d(1, 1, 1);
        -webkit-animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
        animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
        opacity: 1;
    } */
}
.toggle-enter-active{
  animation: toggle .36s;
}
.toggle-leave-active{
  animation: toggle .36s reverse;
}

</style>
